home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 386 / insttest / compare.s < prev    next >
Text File  |  1985-11-19  |  2KB  |  72 lines

  1.  ; Program Name: COMPARE.S
  2.  ;      Version: 1.003
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;    Assemble in PC-relative mode and save with a TOS extension.
  7.  
  8.  ; Program Function:
  9.  
  10.  ;    Compares the relative speed and memory requirements of
  11.  
  12.  ;                         cmpi.l #d8, dn
  13.  
  14.  ;    to                   moveq #d8, dm
  15.  ;                         cmp.l dm, dn
  16.  
  17.  ; in an effort to confirm or refute the assertion on page 202 of the
  18.  ; Kelly-Bootle book that the second algorithm is a faster.  The execution
  19.  ; time reported is for 50,000 executions of each algorithm.
  20.   
  21. calculate_program_size:
  22.  lea        -$102(pc), a1       ; Fetch basepage start address.
  23.  lea        program_end, a0     ; Fetch program end = array address.
  24.  trap       #6                  ; Return unused memory to op system.
  25.  lea        stack, a7
  26.  
  27. initialize_registers_1:
  28.  lea        header_1, a0       
  29.  lea        header_2, a1
  30.  lea        cmpi_start, a3
  31.  lea        cmpi_end, a4
  32.  lea        heading, a5
  33.  move.w     #50000, d7
  34.  trap       #9
  35.  
  36. initialize_registers_2:
  37.  lea        header_3, a0       
  38.  lea        header_4, a1
  39.  lea        moveq_cmp_start, a3
  40.  lea        moveq_cmp_end, a4
  41.  lea        heading, a5
  42.  move.b     #0, (a5)            ; Store a NULL in first byte to create a
  43.  move.w     #50000, d7          ; null string so that heading gets printed
  44.  trap       #9                  ; only once.
  45.  
  46. terminate:
  47.  trap       #8
  48.  
  49. cmpi_start:                
  50.  cmpi.l     #0, d1
  51. cmpi_end:
  52.  
  53. moveq_cmp_start:        
  54.  moveq      #0, d0
  55.  cmp.l      d0, d1  
  56. moveq_cmp_end:
  57.  
  58.  data
  59. heading:      dc.b       "COMPARE Program Results",$D,$A,$D,$A,0
  60. header_1:     dc.b       "  Elapsed time for cmpi.l #d8, dn:    ",0
  61. header_2:     dc.b       "  Memory required for first algorithm:   ",0
  62. header_3:     dc.b $D,$A,"  Elapsed time for moveq  #d8, dm",$D,$A
  63.               dc.b       "                   cmp.l   dm, dn:    ",0
  64. header_4:     dc.b       "  Memory required for second algorithm:  ",0
  65.  bss
  66.  align
  67. label:        ds.l  1
  68.               ds.l 96
  69. stack:        ds.l  0
  70. program_end:  ds.l  0 
  71.  end
  72.